import apiExample from './interface/example'
import apiLogin from './interface/login'
import apiRegister from './interface/register'
import apiPublish from './interface/publish'
import apiSubstitute from './interface/substitute'
import apiMine from './interface/mine'

const install = Vue => {
  if (install.installed) {
    return
  }
  install.installed = true
  Object.defineProperties(Vue.prototype, {
    $http: {
      get () {
        // PS: 这里没有区分命名空间
        return Object.assign(
          {},
          apiExample,
          apiRegister,
          apiLogin,
          apiPublish,
          apiSubstitute,
          apiMine
        )
        // 如果需要区分命令空间的话可以参考以下写法
        // {
        //     apiLogin,
        //     apiRegister,
        //     apiPublish
        // }
      }
    }
  })
}

export default install
